package cn.harry.modular.sys.domain;

import cn.harry.common.mybatis.base.BaseEntity;
import cn.hutool.core.date.DatePattern;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 后台用户表
 *
 * @author honghh Date 2019-10-14 10:39:25 Copyright (C) www.tech-harry.cn
 */
@Data
@TableName(value = "sys_user", autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
public class SysUser extends BaseEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 *
	 */
	@TableId
	private Long id;

	/**
	 * 所属部门
	 */
	@Schema(description = "所属部门")
	private Long deptId;

	/**
	 * 所属部门名称
	 */
	@Schema(description = "所属部门名称")
	private String deptName;

	/**
	 * 所属岗位
	 */
	@Schema(description = "所属岗位")
	@TableField(value = "post_ids", typeHandler = JacksonTypeHandler.class)
	private JSONArray postIds;

	/**
	 * 登陆用户名
	 */
	@Schema(description = "登陆用户名")
	private String username;

	/**
	 * 密码
	 */
	private String password;

	/**
	 * 头像
	 */
	@Schema(description = "头像")
	private String icon;

	/**
	 * 邮箱
	 */
	@Schema(description = "邮箱")
	private String email;

	/**
	 * 手机号码
	 */
	@Schema(description = "手机号")
	private String phone;

	/**
	 * 昵称
	 */
	@Schema(description = "昵称")
	private String nickName;

	/**
	 * 性别
	 */
	@Schema(description = "性别")
	private String sex;

	/**
	 * 备注信息
	 */
	@Schema(description = "备注信息")
	private String note;

	/**
	 * 最后登陆IP
	 */
	@Schema(description = "最后登陆IP")
	private String loginIp;

	/**
	 * 最后登录时间
	 */
	@Schema(description = "最后登录时间")
	@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
	private Date loginTime;

	/**
	 * 帐号启用状态：0->禁用；1->启用
	 */
	@Schema(description = "帐号启用状态：0->禁用；1->启用")
	private String status;

	/**
	 * 有效状态：0->无效；1->有效
	 */
	@Schema(description = "有效状态：0->无效；1->有效")
	@TableLogic
	private Integer valid;

	/**
	 * 角色ID列表
	 */
	@Schema(description = "角色ID列表")
	@TableField(exist = false)
	private List<Long> roleIds;

}
